﻿#region Copyright (c) 2013 James Snape
// <copyright file="TaskContextFeature.cs" company="James Snape">
//  Copyright 2013 James Snape
// 
//  Licensed under the Apache License, Version 2.0 (the "License");
//  you may not use this file except in compliance with the License.
//  You may obtain a copy of the License at
// 
//  http://www.apache.org/licenses/LICENSE-2.0
// 
//  Unless required by applicable law or agreed to in writing, software
//  distributed under the License is distributed on an "AS IS" BASIS,
//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
//  See the License for the specific language governing permissions and
//  limitations under the License.
// </copyright>
#endregion

namespace Deeply.Tests.Fixtures
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;

    /// <summary>
    /// TaskContextFeature class definition.
    /// </summary>
    /// <typeparam name="T">The type of task that will be created.</typeparam>
    public class TaskContextFeature<T> : SimpleContextFixture where T : ITask
    {
        /// <summary>
        /// Task under test.
        /// </summary>
        private T task;

        /// <summary>
        /// Initializes a new instance of the <see cref="TaskContextFeature{T}"/> class.
        /// </summary>
        /// <param name="createTask">Function used to create the typed task.</param>
        public TaskContextFeature(Func<T> createTask)
        {
            if (createTask == null)
            {
                throw new ArgumentNullException("createTask");
            }

            this.task = createTask();
        }

        /// <summary>
        /// Gets the task under test.
        /// </summary>
        public T Task
        {
            get { return this.task; }
        }
    }
}
